﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace MyWeb.Data
{
	public class tb_AdminDAL : SqlDataProvider
	{

		#region[tb_Admin_GetbyAll]
		public DataTable tb_Admin_GetByAll()
		{
            using (var cmd = new SqlCommand("sp_tb_Admin_GetbyAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_Admin_GetbyId]
		public DataTable tb_Admin_GetById(tb_AdminInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_Admin_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Username", Data.Username));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion

        #region[tb_Admin_CheckLogin]
        public DataTable tb_Admin_CheckLogin(string Username,string Password)
        {
            using (var cmd = new SqlCommand("sp_tb_Admin_CheckLogin", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@Username", Username));
                cmd.Parameters.Add(new SqlParameter("@Password", Password));
                var da = new SqlDataAdapter(cmd);
                var dt = new DataTable();
                da.Fill(dt);
                return dt;
            }
        }
        #endregion
		#region[tb_Admin_GetbyTop]
		public DataTable tb_Admin_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_tb_Admin_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_Admin_Insert]
		public void tb_Admin_Insert(tb_AdminInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_Admin_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Username", Data.Username));
				cmd.Parameters.Add(new SqlParameter("@Password", Data.Password));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tb_Admin_Update]
		public void tb_Admin_Update(tb_AdminInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_Admin_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Username", Data.Username));
				cmd.Parameters.Add(new SqlParameter("@Password", Data.Password));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tb_Admin_Delete]
		public void tb_Admin_Delete(string Id)
		{
			using (var cmd = new SqlCommand("sp_tb_Admin_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Username", Id));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion

	}
}